<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="dominio.SolicitudArticulo"%>
<%@page language="java" import="java.util.*"%>

<h1>Lista de Solicitudes de Articulos</h1>
<div class="table-responsive">
	<table class="table table-bordered table-striped">
		<thead>
			<tr>
				<th>Codigo de Solicitud</th>
				<th>Codigo de Despacho</th>
				<th>Fecha</th>
				<th>Estado</th>
				<th>Ir a Fabricar</th>
				<th>Ir a Entregar</th>
			</tr>
		</thead>
		<tbody>
			<%
				List<SolicitudArticulo> data = (List<SolicitudArticulo>) request
						.getAttribute("data");
				for (Iterator<SolicitudArticulo> itr = data.iterator(); itr
						.hasNext();) {
					SolicitudArticulo solicitudArticulo = itr.next();
					String linkFabricar = request.getContextPath()
							+ "/solicitudArticulo?idSolicitud="
							+ solicitudArticulo.getIdSolicitud() + "&idModulo="
							+ solicitudArticulo.getIdModulo();
					String linkEntregar = request.getContextPath()
							+ "/solicitudArticuloEntrega?idSolicitud="
							+ solicitudArticulo.getIdSolicitud() + "&idModulo="
							+ solicitudArticulo.getIdModulo();
			%>
			<tr>
				<td><span><%=solicitudArticulo.getIdSolicitud()%></span></td>
				<td><span><%=solicitudArticulo.getIdModulo()%></span></td>
				<td><span><%=solicitudArticulo.getFechaString()%></span></td>
				<td><span><%=solicitudArticulo.getEstado().toString()%></span></td>
				<%if (!solicitudArticulo.estaEntregada()) {%>
					<%if (solicitudArticulo.estaParaFabricar()) { %>
					<td><a id="linkSolicitudArticuloFabrica" data-link="<%=linkFabricar%>">A Fabricar</a></td>
					<%} else {%>
					<td></td>
					<%}%>
					<%if (solicitudArticulo.estaParaEnviar() || solicitudArticulo.estaParaFabricar()) { %>
					<td><a id="linkSolicitudArticuloEntrega" data-link="<%=linkEntregar%>">A Entregar</a></td>
					<%} else {%>
					<td></td>
					<%}%>
				<%} else {%>
					<td></td><td></td>
				<%}%>
			</tr>
			<%}%>
		</tbody>
	</table>
</div>
<script type="text/javascript" src="js/tpia.js"></script>
